﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

delegate int NumberChanger(int n);

namespace FunctionalityTests
{

   class TestDelegate
   {
      int num = 10;
      public int AddNum(int p)
      {
         num += p;
         return num;
      }

      public int MultNum(int q)
      {
         num *= q;
         return num;
      }
      
      public int getNum()
      {
         return num;
      }

      void runTest()
      {
         //create delegate instances
         NumberChanger nc;
         NumberChanger nc1 = new NumberChanger(AddNum);
         NumberChanger nc2 = new NumberChanger(MultNum);
         nc = nc2;
         nc += nc1;
         //calling multicast
         nc(5);
         Console.WriteLine("Value of Num: {0}", getNum());
         Console.ReadKey();
      }
   }
}